package com.ly.designpatten.factory;

import com.ly.designpatten.factory.common.Pizza;
import org.springframework.cglib.proxy.Factory;

/**
 * @Classname AbstractFactory
 * @Description TODO
 * @Date 2020/10/7 14:30
 * @Author 冷心影翼
 */
public abstract class AbstractFactory {
	 public abstract Pizza createA();
	 public abstract Pizza createB();
}

interface IFactory {
	void create();
}

class ShangHaiPissaA extends Pizza implements IFactory {

	public ShangHaiPissaA() {
		create();
	}
	@Override
	public void create() {
		System.out.println("ShangHaipissaA");
	}

	@Override
	public void pre() {

	}
}

class ShangHaiPissaB extends Pizza implements IFactory {
	public ShangHaiPissaB() {
		create();
	}

	@Override
	public void create() {
		System.out.println("ShangHaipissaB");
	}

	@Override
	public void pre() {

	}
}


class ShiChuanPissaA extends Pizza implements IFactory {
	public ShiChuanPissaA() {
		create();
	}
	@Override
	public void create() {
		System.out.println("ShiChuanPissaA");
	}

	@Override
	public void pre() {

	}
}
class ShiChuanPissaB extends Pizza implements IFactory {
	public ShiChuanPissaB() {
		create();
	}

	@Override
	public void create() {
		System.out.println("ShiChuanPissaB");
	}

	@Override
	public void pre() {

	}
}



class ShangHaiPissaFactory extends AbstractFactory {

	@Override
	public Pizza createA() {
		return new ShangHaiPissaA();
	}

	@Override
	public Pizza createB() {
		return new ShangHaiPissaB();
	}
}


class ShiChuanPizzaBFactory extends AbstractFactory {

	@Override
	public Pizza createA() {
		return new ShiChuanPissaA();
	}

	@Override
	public Pizza createB() {
		return new ShiChuanPissaB();
	}
}


class Test {
	public static void main(String[] args) {
		ShiChuanPizzaBFactory shiChuanPizzaBFactory = new ShiChuanPizzaBFactory();
		shiChuanPizzaBFactory.createA();
		shiChuanPizzaBFactory.createB();
		ShangHaiPissaFactory shangHaiPissaFactory = new ShangHaiPissaFactory();
		shangHaiPissaFactory.createA();
		shangHaiPissaFactory.createB();
	}
}